﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace leviathan_mapeditor.loadScenario
{
    public partial class loadForm : Form
    {
        MainForm main;

        public loadForm(ref MainForm m)
        {
            InitializeComponent();
            main = m;
        }

        private void loadForm_Load(object sender, EventArgs e)
        {
            string path = "../../saves/SList.lst";

            if (!System.IO.File.Exists(path))
            {
                System.IO.File.Create(path);
            }

            using (System.IO.StreamReader sr = new System.IO.StreamReader(path))
            {
                while (!sr.EndOfStream)
                {
                    comboBox1.Items.Add(sr.ReadLine());
                }
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if ("" != comboBox1.Text)
            {
                main.loadScenario(comboBox1.Text);
                this.Close();
                return;
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("Válassz egy fájlt!", "Hiba!");
                return;
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
